package com.book.controller;

import com.book.service.BookDetailService;
import com.book.util.BaseResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * <p>
 * 书本详情 前端控制器
 * </p>
 *
 * @author auto
 * @since 2025-04-04 10:57:26
 */
@RestController
@RequestMapping("/book-detail")
@Tag(name = "书本详情", description = "书本详情相关接口")
public class BookDetailController {

    @Autowired
    private BookDetailService bookDetailService;

    @GetMapping("/{id}")
    @ApiOperation(value = "根据书本查询书本详情")
    public BaseResult<?> getBookDetailById(@PathVariable("id") String id) {
        return BaseResult.successResult(bookDetailService.getBookDetailById(id));
    }

    @GetMapping("/getByIsbn/{id}")
    @ApiOperation(value = "根据书本ISBN查询书本详情")
    public BaseResult<?> getBookDetailByIsbn(@PathVariable("id") String id) throws IOException {
        return BaseResult.successResult(bookDetailService.getBookDetailByIsbn(id));
    }
}
